package com.waste.game.service;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.waste.game.entity.entitiytv.VideoUserBean;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service("TokenService")
public class TokenService {
    public String getToken(VideoUserBean videoUserBean) {
        String token="";
        token= JWT.create().withAudience(videoUserBean.getId()+"", videoUserBean.getUserName())// 将 user id 保存到 token 里面
                .sign(Algorithm.HMAC256(videoUserBean.getUserPassWord()));// 以 password 作为 token 的密钥
        return token;
    }
}
